using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using DevExpress.XtraGrid.Views.Base;
using DevExpress.XtraGrid.Views.Grid;
namespace LPV_POS.manhinh
{
    
    public partial class mh_grid_parent_child : DevExpress.XtraEditors.XtraForm
    {
        private DataSet ds;
        private DataTable tb;
        thuvien tv;
        string[] s;
        
        object[] o;
        private DataTable showdataon_gridnhomchu()
        {
            s = new string[] {"@flag","@choose" };
            o = new object[] {1,1 };
            tv = new thuvien();
            tb = tv.SP_SelectDataTable("sp_mh_select_hanghh",s,o);
            return tb;
        }
        private DataTable showdataon_gridnhomhang()
        {
            s = new string[] { "@flag", "@choose" };
            o = new object[] { 1, 2 };
            tv = new thuvien();
            tb = tv.SP_SelectDataTable("sp_mh_select_hanghh", s, o);
            return tb;
        }
        public mh_grid_parent_child()
        {
            InitializeComponent();
        }

        private void mh_grid_parent_child_Load(object sender, EventArgs e)
        {
            thuvien.Chuoi_CSDL = @"Data Source=RAD03\SQLEXPRESS;Initial Catalog=LPV_POS;Integrated Security=True";
            DataTable tb_nhomchu = showdataon_gridnhomchu();
            DataTable tb_nhomhang = showdataon_gridnhomhang();
            ds = new DataSet();
            ds.Tables.Add(tb_nhomchu);
            ds.Tables.Add(tb_nhomhang);
            ds.Relations.Add("chu_nhom", tb_nhomchu.Columns["OBJID"], tb_nhomhang.Columns["MANHOMCHU"]);
            luoi_nhomchu.MainView = grid_nhomchu;
            luoi_nhomchu.DataSource = tb_nhomchu;
            
        }

      
        // xoa dong
        private void simpleButton1_Click(object sender, EventArgs e)
        {
            int a = luoi_nhomchu.Views[0].DataRowCount;
            
            string  ten = grid_nhomchu.GetRowCellValue(grid_nhomchu.FocusedRowHandle, col_ten).ToString();
            LPV_POS.Module.MessageBox_LPV.Show(ten);

            int dong;
            dong = ((ColumnView)luoi_nhomchu.Views[0]).FocusedRowHandle;
            DataView tam = (DataView)luoi_nhomchu.Views[0].DataSource;
            tam.Delete(dong);
        }

      
    }
}